<?php
require '../conn.php';
require 'config.php';
require '../inc/function.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="../css/admin.css" type="text/css" />
<script type="text/javascript" src="inc/function.js"></script>
</head>
<body>
<?php
$a_order=ReStra($_POST['a_order']);
$a_title=ReStra(trim($_POST['a_title']));
$a_image=ReStra($_POST['a_image']);
$a_url=ReStra($_POST['a_url']);

switch($act){
case 'add':
	$sql="insert into ".$language."_ad(a_class,a_order,a_title,a_image,a_url) values(2,$a_order,'$a_title','$a_image','$a_url')";
	mysql_query($sql) or die(mysql_error($sql));
	Msg('','');
	break;
case 'modify':
	$image_original=RsField('select a_image from '.$language.'_ad where a_id='.$id);
	$sql="update ".$language."_ad set a_title='$a_title',a_image='$a_image',a_url='$a_url' where a_id=$id";
	mysql_query($sql) or die(mysql_error($sql));
	if ($a_image!=$image_original) DeleteFile('../'.$image_original);
	Msg('','');
	break;
case 'delete':
	$sql='delete from '.$language.'_ad where a_id='.$id;
	mysql_query($sql) or die(mysql_error($sql));
	Msg('','');
	break;
}
?>
<div id="container">
	<?php
	if ($meter==1){
	$query=mysql_query('select * from '.$language.'_ad where a_id='.$id);
	$row=mysql_fetch_array($query);
	switch($row['a_order']){
	case 1:
		$size='336 × 188';
		break;
	case 2:
		$size='326 × 188';
		break;
	case 3:
		$size='165 × 188';
		break;
	case 4:
		$size='167 × 188';
		break;
	case 5:
		$size='336 × 357';
		break;
	case 6:
		$size='162 × 209';
		break;
	case 7:
		$size='162 × 209';
		break;
	case 8:
		$size='334 × 209';
		break;
	case 9:
		$size='326 × 146';
		break;
	case 10:
		$size='334 × 146';
		break;
	}
	?>
    <div class="edit">
      <h1>޸首页最新展会<a href="javascript:location.reload();">刷新</a></h1>
      <form name="form1" method="post" action="?act=modify&id=<?php echo $id ?>" onsubmit="return CheckiExh(this);">
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td class="edit_title">展会名称：</td>
            <td><input type="text" name="a_title" class="inputtext" value="<?php echo $row['a_title']?>" size="80" maxlength="200" /></td>
          </tr>
          <tr>
            <td class="edit_title">展会图片：</td>
            <td><input type="text" name="a_image" id="a_image" class="inputtext" value="<?php echo $row['a_image']?>" size="50" readonly="readonly" />&nbsp;(图片尺寸：<?php echo $size ?>)<iframe src="../upload_fy.php?file_type=0&file_id=a_image" frameborder="0" allowtransparency="true" scrolling="no" width="100%" height="25"></iframe></td>
          </tr>
          <tr>
            <td class="edit_title">链接地址：</td>
            <td><input type="text" name="a_url" class="inputtext" value="<?php echo $row['a_url']?>" size="80" maxlength="255" /></td>
          </tr>
          <tr>
            <td class="edit_title" height="30">&nbsp;</td>
			<td><input type="submit" name="button" class="button" value=" 保存 " />&nbsp;&nbsp;<input type="button" name="button" class="button" value=" 返回 " onclick="history.back();" /></td>
          </tr>
        </table>
      </form>
    </div>
	<?php
	}
	else{
	?>
	<div class="view">
		<h1>首页最新展会<a href="javascript:location.reload();">刷新</a></h1>
	    <table width="100%" border="0" cellpadding="0" cellspacing="0">
        	<tr class="v_title">
				<td width="15%">图片尺寸</td>
            	<td width="15%">展会图片</td>
				<td width="30%">展会名称</td>
            	<td width="30%">链接地址</td>
				<td width="10%">操作</td>
        	</tr>
			<?php
			$col=1;
			$str='';
			$query=mysql_query('select * from '.$language.'_ad where a_class=2 order by a_order,a_id');
			if (mysql_num_rows($query)>0){
			while($row=mysql_fetch_array($query)){
				$str.='<tr onmouseover="this.className=\'view_trover\';" onmouseout="this.className=\'view_trout\';">';
				$str.='<td>';
				switch($row['a_order']){
				case 1:
					$str.='336 × 188';
					break;
				case 2:
					$str.='326 × 188';
					break;
				case 3:
					$str.='165 × 188';
					break;
				case 4:
					$str.='167 × 188';
					break;
				case 5:
					$str.='336 × 357';
					break;
				case 6:
					$str.='162 × 209';
					break;
				case 7:
					$str.='162 × 209';
					break;
				case 8:
					$str.='334 × 209';
					break;
				case 9:
					$str.='326 × 146';
					break;
				case 10:
					$str.='334 × 146';
					break;
				}
				$str.='</td>';
				$str.='<td style="line-height:normal; font-size:0px;"><a href="../'.$row['a_image'].'" target="_blank"><img src="../'.$row['a_image'].'" style="margin:5px auto;" height="60" /></a></td>';
				$str.='<td style="line-height:18px;">'.$row['a_title'].'</td>';
				$str.='<td>'.$row['a_url'].'&nbsp;</td>';
				$str.='<td><a href="?meter=1&id='.$row['a_id'].'">修改</a></td>';
				$str.='</tr>';
				$col++;
			}
			}
			echo $str;
			?>
		</table>
	</div>
    <?php } ?>
</div>
</body>
</html>